/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataAccess;

import Entities.CategoryEntities;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ducdm_b00875
 */
public class CategoryDataAccess {
    
    ConnectDatabase objCD = new ConnectDatabase();
    private List<CategoryEntities> categoryList;
    
    public CategoryDataAccess()
    {
        categoryList = new ArrayList<CategoryEntities>();
    }
    
        public List<CategoryEntities> getCategoryAll() throws Exception, ClassNotFoundException{
        CategoryEntities categoryEntities = null;
        categoryList.clear();
        objCD.open();
        objCD.setMode(ConnectDatabase.CALLABLE);
        objCD.setStatement("{call sp_Category_ViewAll()}");
        objCD.doQuery();
        if (objCD.rs != null) {
            while (objCD.rs.next()) {                
                categoryEntities = new CategoryEntities(objCD.rs.getInt("CategoryId"), objCD.rs.getString("CategoryName"));
                categoryList.add(categoryEntities);
            }
        }
        objCD.close();
        return categoryList;
    }
        
        
}
